package JavaSE_core.IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Demo9 {

	public static void main(String[] args) throws Exception {
		FileInputStream fis=new FileInputStream("c:/a.txt");
		InputStreamReader isr=new InputStreamReader(fis, "UTF-8");//创建字符输入流，并指定编码
		char[] chars=new char[64];
		int len = isr.read(chars);//读取文本文件，并返回读取到的字符数，如果到达文件末尾则返回-1
		System.out.println(len);
		System.out.println(Arrays.toString(chars));
		String s=new String(chars,0,len);
		System.out.println(s);
		isr.close();//会自动关闭fis
//		fis.close();
	}

}
